package cc.abanlee.module.system.service.demo.impl;

import cc.abanlee.framework.common.exception.ServiceException;
import cc.abanlee.module.system.controller.admin.demo.vo.DemoReqVO;
import cc.abanlee.module.system.controller.admin.demo.vo.DemoRespVO;
import cc.abanlee.module.system.enums.ErrorCodeConstants;
import cc.abanlee.module.system.service.demo.DemoService;
import org.springframework.stereotype.Service;

@Service
public class DemoServiceImpl implements DemoService {
    @Override
    public DemoRespVO test(DemoReqVO demoReqVO) {
        DemoRespVO demoRespVO=new DemoRespVO();
        demoRespVO.setName(demoReqVO.getName());
        demoRespVO.setDesc("描述:"+demoReqVO.getName());
        if(demoReqVO.getName().equals("A")){
            throw new ServiceException(ErrorCodeConstants.TEST_ERROR);
        }
        return demoRespVO;
    }

    @Override
    public DemoRespVO test2(Long id) {
        DemoRespVO demoRespVO=new DemoRespVO();
        demoRespVO.setName(String.valueOf(id));
        return demoRespVO;
    }
}
